<?php

namespace common\models\business;

use Yii;

/**
 * This is the model class for table "business_put_detail".
 *
 * @property string $id
 * @property integer $putid
 * @property integer $farmerid
 * @property string $farmer
 * @property integer $num
 */
class BusinessPutDetail extends \yii\db\ActiveRecord
{


    //主要用于日志记录
    public $uselog = [
        'tabcomment' => '投放计划详情',      //用于修改了什么的显示
        'mainfield' => 'id',      //主要的显示标题的字段
        'picturefield' => [],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];


    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'business_put_detail';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['putid', 'farmerid', 'farmer', 'num'], 'required'],
            [['putid', 'farmerid', 'num'], 'integer'],
            [['farmer'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'putid' => '投放计划id',
            'farmerid' => '农户id',
            'farmer' => '农户',
            'num' => '数量',
        ];
    }


    /**
     * @return \yii\db\ActiveQuery
     * 获取代养农户
     */
    public function getPutfarmer()
    {
        return $this->hasOne(BusinessFarmers::className(),['id'=>'farmerid']);
    }


    /**
     * @return \yii\db\ActiveQuery
     * 获取投放计划总数
     */
    public function getPut()
    {
        return $this->hasOne(BusinessPut::className(),['id'=>'putid']);
    }

}
